
<head>
    <title>文件分享</title>
    <style>
        body{
            margin: 0;
            background-image: url(./../img/w.jpg);
            background-size: cover;
        }
        .one{
            height: 200px;
            width: 450px;
            margin: 50px auto;
            background-color: rgba(36,75,116, 0.5);
            border-radius:15px;
        }
        .one label{color:#F6F6F6;font-size:30px;}
        .a{
            height: 30px;
            width: 100px;
            margin-left: 175px;
            background-color:#f9f0af;
        }
        .two{
            width: 800px;
            margin: 0 auto;
            background-color: rgba(36,75,116, 0.5);
            border-radius:5px;
        }
    </style>
</head>
<body >
    <div class="one">
        <form action="" method="post" enctype="multipart/form-data">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label for="file">文件名：</label>
            <input type="file" name="file" id="file" >
            <br><br><br><br><br><br>
            <input type="submit" name="filepost" value="提交" class="a">
        </form>
    </div>
    <div class="two">
            <?php
                // 文件浏览与上传下载
                if(isset($_GET['path'])) { // 文件路径 本文件地址?path=路径
                    $filePath = $_GET['path'];
                } else {
                    $filePath = '.';
                }
                
                if(isset($_POST['filepost'])) {
                    $url = $filePath."/".$_FILES['file']['name'];
                    if(move_uploaded_file($_FILES['file']['tmp_name'],$url)) {
                        echo '文件上传成功';
                        echo '<br>';
                    } else {
                        echo '文件上传失败';
                        echo '<br>';
                    }
                }
                $handle = opendir($filePath);
                echo '<table border="0" width="800" cellspacing="0" cellpadding="0">';
                echo '<tr align="left" bgcolor="#F6F6F6">';
                            echo '<th>文件名</th>
                                    <th>文件大小</th>
                                    <th>文件类型</th>
                                    <th>创建时间</th>
                                    <th>修改时间</th>
                                    <th>是否可读</th>
                                    <th>是否可写</th>
                                    <th>可执行</th>
                        </tr>';
                    while ($file = readdir($handle)) {
                        if($file!='.'&&$file!='..'&&$file!='share.php'){
                            $dirFile = $filePath . "/" . $file;
                            echo '<tr>';
                            if(filetype($dirFile) == 'file') {
                                echo '<td>
                                        <a href="'.$dirFile.'" download="'.$file.'">' . $file . '</a>
                                    </td>'; // 文件名
                            }else if (filetype($dirFile) == 'dir') {
                                echo '<td>' . $file . '</td>'; // 文件夹名
                            }
                                echo '<td>' . filesize($dirFile) . '</td>';
                                echo '<td>' . filetype($dirFile) . '</td>';
                                echo '<td>' . date("Y/n/t", filectime($dirFile)) . '</td>';
                                echo '<td>' . date("Y/n/t", filemtime($dirFile)) . '</td>';
                                $read = is_readable($dirFile) ? '支持' : '不支持';
                                $writable = is_writable($dirFile) ? '支持' : '不支持';
                                $executetable = is_executable($dirFile) ? '支持' : '不支持';
                                echo '<td align="center">' . $read . '</td>';
                                echo '<td align="center">' . $writable . '</td>';
                                echo '<td align="center">' . $executetable . '</td>';
                                echo '</tr>';
                        }
                    }echo '</table>';
            ?>
    </div>
</body>
